Open
Conversation
dardecena
requested changes
Oct 22, 2025
dardecena
left a comment
There was a problem hiding this comment.
Great effort. You are almost there. Please work on Ex 4 and Ex 5.
Comment on lines
+21
to
+38
| const ul = document.createElement ('ul'); | ||
| books.forEach( book => { | ||
| const li = document.createElement ('li'); | ||
| const p = document.createElement ( 'p'); | ||
| p.textContent = `${book.title} - ${book.author} `; | ||
| const img = document.createElement ('img'); | ||
| img.src = `https://covers.openlibrary.org/b/isbn/${book.isbn}-M.jpg`; | ||
| img.alt = `${book.title} cover`; | ||
| li.appendChild (p); | ||
| li.appendChild (img); | ||
| if (book.alreadyRead) { | ||
| li.style.backgroundColor = 'green'; | ||
| } | ||
| else | ||
| { li.style.backgroundColor = 'red'} ; | ||
| ul.appendChild (li); | ||
| }); | ||
| return ul; |
Comment on lines
+2
to
+37
| body { | ||
| font-family: Arial, sans-serif; | ||
| background-color: #f4f4f4; | ||
| margin: 0; | ||
| padding: 20px; | ||
| } | ||
| h1 { | ||
| text-align: center; | ||
| color: #333; | ||
| } | ||
| ul { | ||
| list-style-type: none; | ||
| padding: 0; | ||
| display : grid ; | ||
| grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); | ||
| gap : 16px; | ||
|
|
||
| } | ||
| li { | ||
| background: #fff; | ||
| margin: 10px 0; | ||
| padding: 15px; | ||
| border-radius: 5px; | ||
| box-shadow: 0 2px 4px rgba(0,0,0,0.1); | ||
| } | ||
| img { | ||
| width: 100% ; | ||
| height: auto ; | ||
| border -radius: 5px ; | ||
| display : block ; | ||
|
|
||
| } | ||
| p { | ||
| margin: 0; | ||
| padding: 0; | ||
| } |
Comment on lines
+11
to
+23
| function aboutMe() { | ||
| const nickname = document.querySelector ('#nickname'); | ||
| nickname.textContent = 'Rim'; | ||
| const favFood = document.querySelector ('#fav-food'); | ||
| favFood.textContent = 'Sushi'; | ||
| const hometown = document.querySelector ('#hometown'); | ||
| hometown.textContent = 'Tokyo'; | ||
| const listItems = document.querySelectorAll ('li'); | ||
| listItems.forEach(item => { | ||
| item.classList.add('list-item'); | ||
| }); | ||
| } | ||
| aboutMe(); |
Comment on lines
+1
to
+11
|
|
||
| body { | ||
|
|
||
| font-family: Arial, sans-serif; | ||
| margin: auto; | ||
| padding: 20px; | ||
| } | ||
|
|
||
| .list-item { | ||
| color: red ; | ||
| } No newline at end of file |
Comment on lines
+10
to
+13
| const logo = document.querySelector('img[alt="Google"]') ; | ||
| logo.src = 'https://www.hackyourfuture.be/static/logo.png'; | ||
| logo.srcset = 'https://www.hackyourfuture.be/static/logo.png'; | ||
|
|
Comment on lines
+10
to
+11
| document.querySelector('time').textContent= new Date().toLocaleTimeString() ; | ||
| setInterval(addCurrentTime, 1000) ; |
There was a problem hiding this comment.
TODO: Almost there, but not quite.
Hint:
Where on the document do you want to display the time? header? body? etc.
Comment on lines
+23
to
+60
| window.addEventListener('load', function () { | ||
| const cat = document.querySelector('img'); | ||
| const originalSrc = cat.src || 'http://www.anniemation.com/clip_art/images/cat-walk.gif'; | ||
| const danceSrc = 'https://media1.tenor.com/images/2de63e950fb254920054f9bd081e8157/tenor.gif'; | ||
|
|
||
| cat.style.position = 'absolute'; | ||
| cat.style.left = '0px'; | ||
|
|
||
| let hasDanced = false; | ||
| let walkTimer = null; | ||
|
|
||
| function catWalk() { | ||
| const x = parseInt(cat.style.left, 10) || 0; | ||
| const rightEdge = window.innerWidth - cat.width; | ||
| const mid = rightEdge / 2; | ||
|
|
||
| if (x >= rightEdge) { | ||
| cat.style.left = '0px'; | ||
| hasDanced = false; | ||
| return; | ||
| } | ||
|
|
||
| if (!hasDanced && x >= mid) { | ||
| hasDanced = true; | ||
| clearInterval(walkTimer); | ||
| cat.src = danceSrc; | ||
| setTimeout(function () { | ||
| cat.src = originalSrc; | ||
| walkTimer = setInterval(catWalk, 50); | ||
| }, 5000); | ||
| return; | ||
| } | ||
|
|
||
| cat.style.left = (x + 10) + 'px'; | ||
| } | ||
|
|
||
| walkTimer = setInterval(catWalk, 50); | ||
| }); |
There was a problem hiding this comment.
TODO: Good effort but not quite there yet. I see the cat walking in place. It doesn't meet the requirements of walking across the screen from left to right and doing a dance for 50ms in the middle of the screen.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.